package com.atguigu.udmp.web.userprofile.mapper;


import com.atguigu.udmp.web.userprofile.bean.UserGroup;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2021-05-04
 */


@Mapper
@DS("mysql")
public interface UserGroupMapper extends BaseMapper<UserGroup> {

    @Insert("${sql}")
    @DS("olap")
    public  void  insertBitmapSQL(@Param("sql") String sql);

    //mybatis 每行数据会封装到list中每个元素   要进入list多个元素 ，要把doris炸开为多行
    @Select("select   us from    from user_group lateral view explode( bitmap_to_array(uids) ) bitmapArray as us   where user_group_id=#{userGroupId}")
    @DS("olap")
    public  String[] selectUidList(@Param("userGroupId") String userGroupId);

    @Select("${sql}")
    @DS("olap")
    public  String[] selectUidListBySQL(@Param("sql") String sql);


    @Select("${sql}")
    @DS("olap")
    public Long  selectUserGroupNum(@Param("sql") String sql);


    @Delete("  delete from  user_group where user_group_id=#{userGroupId}")
    @DS("olap")
    public  void  deleteUserGroup(@Param("userGroupId") String userGroupId);

}
